package com.yinhai.activity;



import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.TextView;

/**
 * UpdateActivity （版本更新）
 * 
 * @author Juyon
 */
public class WebViewActivity extends Activity {

//	private WebView webview;
	private WebView wv;

	private TextView title;

	/*
	 * (non-Javadoc)
	 * 
	 * @see android.app.Activity#onCreate(android.os.Bundle)
	 */
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		Bundle extras = getIntent().getExtras();
//		setContentView(R.layout.help);
		String titleStr = extras.getString("title");
		String url = extras.getString("url");

		setContentView(R.layout.more_webview);

		title = (TextView) findViewById(R.id.head_title);
		title.setText(titleStr);

		wv = (WebView) findViewById(R.id.url_webview);
//		wv = (WebView) findViewById(R.id.webView1);
		wv.getSettings().setJavaScriptEnabled(true);
		wv.setScrollBarStyle(0);
		WebSettings webSettings = wv.getSettings();
		webSettings.setAllowFileAccess(true);
		webSettings.setBuiltInZoomControls(true);
		wv.loadUrl(url);
		// 加载数据
		wv.setWebViewClient(new WebViewClient() {
			 @Override
				public void onLoadResource(WebView view, String url) {
					super.onLoadResource(view, url);
				}
			 @Override  
		     public void onPageFinished(WebView view, String url) {  
		        }  
		});

		// 这个是当网页上的连接被点击的时候
		wv.setWebViewClient(new WebViewClient() {
			public boolean shouldOverrideUrlLoading(final WebView view,
					final String url) {
				view.loadUrl(url);
				return true;
			}
		});

	}

//	public void doBack(View view) {
//		onBackPressed();
//	}
	public boolean onKeyDown(int keyCoder, KeyEvent event) {
		if (wv.canGoBack() && keyCoder == KeyEvent.KEYCODE_BACK) {
			wv.goBack();
			return true;
		}
		return false;
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		return true;
	}
	public void doBack(View view) {
		onBackPressed();
	}
}
